package com.yourgroup.common.exception;

/**
 * 29548
 * IntelliJ IDEA
 * 12:40
 * 星期二
 */

public class Result<T> {
    private int code;
    private String msg;
    private T data;

    // 成功响应
    public static <T> Result<T> success(T data) {
        Result<T> result = new Result<>();
        result.code = ErrorCode.SUCCESS.getCode();
        result.msg = ErrorCode.SUCCESS.getMsg();
        result.data = data;
        return result;
    }

    // 错误响应
    public static <T> Result<T> error(ErrorCode errorCode) {
        Result<T> result = new Result<>();
        result.code = errorCode.getCode();
        result.msg = errorCode.getMsg();
        return result;
    }

    // getter/setter
}
